package com.norbitltd.guavaleaves.java.lang;

import org.apache.commons.lang3.StringUtils;

import com.google.common.base.Predicate;

public class CharSequencePredicates {
	/**
	 * @see org.apache.commons.lang3.StringUtils.contains
	 */ 
	public static Predicate<CharSequence> contains(final char searchChar) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.contains(arg0, searchChar);
			}			
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.contains
	 */
	public static Predicate<CharSequence> contains(final CharSequence searchStr) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.contains(arg0, searchStr);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.containsAny
	 */
	public static Predicate<CharSequence> containsAny(final char... searchChars) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.containsAny(arg0, searchChars);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.containsAny
	 */
	public static Predicate<CharSequence> containsAny(final CharSequence searchChars) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.containsAny(arg0, searchChars);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.containsIgnoreCase
	 */
	public static Predicate<CharSequence> containsIgnoreCase(final CharSequence searchStr) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.containsIgnoreCase(arg0, searchStr);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.containsNone
	 */
	public static Predicate<CharSequence> containsNone(final char... invalidChars) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.containsNone(arg0, invalidChars);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.containsNone
	 */
	public static Predicate<CharSequence> containsNone(final String invalidChars) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.containsNone(arg0, invalidChars);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.containsOnly
	 */
	public static Predicate<CharSequence> containsOnly(final char... validChars) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.containsOnly(arg0, validChars);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.containsOnly
	 */
	public static Predicate<CharSequence> containsOnly(final String validChars) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.containsOnly(arg0, validChars);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.endsWith
	 */
	public static Predicate<CharSequence> endsWith(final CharSequence suffix) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.endsWith(arg0, suffix);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.StringUtils.endsWithIgnoreCase
	 */
	public static Predicate<CharSequence> endsWithIgnoreCase(final CharSequence suffix) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.endsWithIgnoreCase(arg0, suffix);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isAllLowerCase
	 */
	public static Predicate<CharSequence> isAllLowerCase() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isAllLowerCase(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isAllUpperCase
	 */
	public static Predicate<CharSequence> isAllUpperCase() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isAllUpperCase(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isAlpha
	 */
	public static Predicate<CharSequence> isAlpha() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isAlpha(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isAlphanumeric
	 */
	public static Predicate<CharSequence> isAlphanumeric() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isAlphanumeric(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isAlphanumericSpace
	 */
	public static Predicate<CharSequence> isAlphanumericSpace() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isAlphanumericSpace(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isAlphaSpace
	 */
	public static Predicate<CharSequence> isAlphaSpace() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isAlphaSpace(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isAsciiPrintable
	 */
	public static Predicate<CharSequence> isAsciiPrintable() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isAsciiPrintable(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isBlank
	 */
	public static Predicate<CharSequence> isBlank() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isBlank(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isEmpty
	 */
	public static Predicate<CharSequence> isEmpty() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isEmpty(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isNotBlank
	 */
	public static Predicate<CharSequence> isNotBlank() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isNotBlank(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isNotEmpty
	 */
	public static Predicate<CharSequence> isNotEmpty() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isNotEmpty(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isNumeric
	 */
	public static Predicate<CharSequence> isNumeric() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isNumeric(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isNumericSpace
	 */
	public static Predicate<CharSequence> isNumericSpace() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isNumericSpace(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.isWhitespace
	 */
	public static Predicate<CharSequence> isWhitespace() {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.isWhitespace(arg0);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.startsWith
	 */
	public static Predicate<CharSequence> startsWith(final CharSequence prefix) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.startsWith(arg0, prefix);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.startsWithAny
	 */
	public static Predicate<CharSequence> startsWithAny(final CharSequence... prefixes) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.startsWithAny(arg0, prefixes);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang.StringUtils.startsWithIgnoreCase
	 */
	public static Predicate<CharSequence> startsWithIgnoreCase(final CharSequence prefix) {
		return new Predicate<CharSequence>() {
			public boolean apply(CharSequence arg0) {
				return StringUtils.startsWithIgnoreCase(arg0, prefix);
			}
		};
	}
}
